package sbt.pages;

import static org.openqa.selenium.support.ui.ExpectedConditions.*;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select;

public class FilmPage extends InternalPage {

	public FilmPage(PageManager pages) {
		super(pages);
	}
	

@FindBy(css = ".center > nav > ul > li > a[href *='logout']")
 private WebElement logoutLink;

@FindBy (xpath= "//div[@id='movie']//div[@class='maininfo_full']/h2")
 private WebElement FilmCont;

//@FindBy (css = "//section/nav//div [@class = 'button']//a [contains(@onclick, './?go=delete')")
 @FindBy(css = "nav a[onclick *= 'delete']")
 private WebElement removeFilmLink;

 public InternalPage  clickRemoveFilm() {
	 removeFilmLink.click();
     wait.until(alertIsPresent()).accept();
     return pages.internalPage;

 }
 public LoginPage clickLogoutLink() {
    logoutLink.click();
    wait.until(alertIsPresent()).accept();
    return pages.loginPage;
  }
  
  public String getFilmName() {
	  return FilmCont.getText();
  }

  public FilmPage ensurePageLoaded() {
    super.ensurePageLoaded();
    wait.until(presenceOfElementLocated(By.xpath("//div [@id = 'movie']")));
    return this;
  }
}
